package com.findFish.fish.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.fish.domain.FishBehavior;
import com.findFish.fish.service.IFishBehaviorService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 鱼类行为分析Controller
 * 
 * @author admin
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/fish/behavior")
public class FishBehaviorController extends BaseController
{
    @Autowired
    private IFishBehaviorService fishBehaviorService;

    /**
     * 查询鱼类行为分析列表
     */
    @PreAuthorize("@ss.hasPermi('fish:behavior:list')")
    @GetMapping("/list")
    public TableDataInfo list(FishBehavior fishBehavior)
    {
        startPage();
        List<FishBehavior> list = fishBehaviorService.selectFishBehaviorList(fishBehavior);
        return getDataTable(list);
    }

    /**
     * 导出鱼类行为分析列表
     */
    @PreAuthorize("@ss.hasPermi('fish:behavior:export')")
    @Log(title = "鱼类行为分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FishBehavior fishBehavior)
    {
        List<FishBehavior> list = fishBehaviorService.selectFishBehaviorList(fishBehavior);
        ExcelUtil<FishBehavior> util = new ExcelUtil<FishBehavior>(FishBehavior.class);
        util.exportExcel(response, list, "鱼类行为分析数据");
    }

    /**
     * 获取鱼类行为分析详细信息
     */
    @PreAuthorize("@ss.hasPermi('fish:behavior:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fishBehaviorService.selectFishBehaviorById(id));
    }

    /**
     * 新增鱼类行为分析
     */
    @PreAuthorize("@ss.hasPermi('fish:behavior:add')")
    @Log(title = "鱼类行为分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FishBehavior fishBehavior)
    {
        return toAjax(fishBehaviorService.insertFishBehavior(fishBehavior));
    }

    /**
     * 修改鱼类行为分析
     */
    @PreAuthorize("@ss.hasPermi('fish:behavior:edit')")
    @Log(title = "鱼类行为分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FishBehavior fishBehavior)
    {
        return toAjax(fishBehaviorService.updateFishBehavior(fishBehavior));
    }

    /**
     * 删除鱼类行为分析
     */
    @PreAuthorize("@ss.hasPermi('fish:behavior:remove')")
    @Log(title = "鱼类行为分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fishBehaviorService.deleteFishBehaviorByIds(ids));
    }
}
